package com.lxq.action;

import com.lxq.model.Role;
import com.lxq.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

@Controller
@RequestMapping("/role")
public class roleaction {


    @RequestMapping("/firstshow")
    public String addRole(RedirectAttributes ras, Role role, User user) {

        ras.addFlashAttribute("role", role);
        ras.addFlashAttribute("user", user);

        return "redirect:/role/showroles.do";

    }

    @RequestMapping("/showroles")
    public ModelAndView showRole(Role role, User user) {
        ModelAndView mv = new ModelAndView();
        mv.setView(new MappingJackson2JsonView());

        System.out.println(role.getRole());
        mv.addObject("user", user);

        return mv;
    }
}
